﻿using VisualWip.Core;
using VisualWip.TFS2010Common;

namespace VisualWip.TFS2010PersistanceProvider
{
    public class TFSConnectionSettingsPath : SettingsPathBase
    {
        public TFSConnectionSettingsPath()
        {
            Connection = new TfsConnection();
        }

        #region Implementation of IPersistable

        public TfsConnection Connection { get; set; }

        public override PersistenceTree Persist(string name)
        {
            var settings = new PersistenceTree(name, this);
            settings.Add(() => Path);
            settings.AddChild(() => Connection);
            return settings;
        }

        public override void Load(PersistenceTree settings)
        {
            Path = settings.Get(() => Path, string.Empty);
            Connection = settings.GetChild(() => Connection, new TfsConnection());
        }

        #endregion
    }
}